package router

import (
	"fmt"
	"gin-admin/global"
	v1 "gin-admin/router/v1"
	v2 "gin-admin/router/v2"
)

var routerLoaders = map[string]func(){
	"v1": v1.LoadV1Routers,
	"v2": v2.LoadV2Routers,
}

func Run() {
	versions := global.GA_CONFIG.Router.Version
	for _, version := range versions {
		if loader, exists := routerLoaders[version]; exists {
			loader()
		} else {
			fmt.Printf("未找到对应的路由加载器: %v\n", version)
		}
	}
	if err := global.GA_ROUTER.Run(fmt.Sprintf(":%v", global.GA_CONFIG.App.Port)); err != nil {
		fmt.Printf("程序启动失败: %v", err)
	}
}
